<?xml version="1.0" encoding="utf-8" ?>
<taskrunner name="eswdl.install" version="1.1" date="2013-07-08" maxthreads="1">

  <!-- 
    Change Log:
      2013-07-08 : teriks28 : OGB project : eSWDL files will not be delivered toghter with Vida any more.
        Added task "create.eswdl.Folder" to make sure there is a folder for the eSWDL library in VIDA.
  -->

  <includes>
    <file name="vida.install.settings.xml" />
  </includes>

  <properties>
    <property key="run.check.directory" value="true"/>
    <property key="run.restore.eswdl" value="true"/>
    <property key="run.Create.eSWDL.Folder" value="true"/>
    <property key="run.install.all.eswdl.files" value="true"/>
    <property key="run.remove.readonly.attribute" value="true"/>
    <property key="run.write.eswdlpath.to.database" value="true"/>
  </properties> 

  <tasks>

    <task name="Write.main.install.type" typename="@WriteInformation">
  <parameters>
        <parameter name="message" value="eswdl.install.xml main.inst.type: ¤{main.install.type}"/>
      </parameters>
    </task>
   
    <!--Make sure there is a folder for the eSWDL library in VIDA.-->
    <task name="create.eswdl.Folder" condition="¤{main.install.type}=INSTALL" typename="@CreateDirectory" run="${run.Create.eSWDL.Folder}">
      <dependencies list=""/>
      <parameters>
        <parameter name="directory" value="${target.eswdl.root}"/>
      </parameters>
    </task>

    <!--Check for Obsolete software files to remove using "eswdl.content" file from stage process
        Only run this for REINSTALL since there are no files to install or remove for clean INSTALL-->
    <task name="install.all.eswdl.files" condition="¤{main.install.type}=REINSTALL" assembly="${a1}" typename="vida.install.eswdl.Install" run="${run.install.all.eswdl.files}">
      <dependencies list=""/>
      <parameters>
        <parameter name="eswdl.content.file.fullpath" value="${install.src.eswdl.content.file.fullpath}"/>
        <parameter name="source.dir" value="${install.src.eswdl.files.dir}"/>
        <parameter name="target.dir" value="${target.eswdl.root}"/>
        <parameter name="diagswdlsession.connectionstring" value="${diagswdlsession.cs}"/>
      </parameters>
    </task>
    
    <!--Just to be on the safe side, allways remove read only attribute on all files in eSWDL library-->
    <task name="remove.readonly.attribute" typename="@CommandLine" run="${run.remove.readonly.attribute}">
      <description>
        removes the attribute read-only on all files in ${target.eswdl.root}
      </description>
      <dependencies list="create.eswdl.Folder,install.all.eswdl.files"/>
      <parameters>
        <parameter name="arguments" value="attrib -r /s"/>
        <parameter name="workingdirectory" value="${target.eswdl.root}"/>
        <parameter name="useCmdExe" value="true"/>
      </parameters>
    </task>    

    <!--Allways write path to eSWDL library in the database-->
    <task name="write.eswdlpath.to.database" typename="@SqlServer.ExecuteStoredProcedure" run="${run.write.eswdlpath.to.database}">
      <description>
        Adds the target.path for eswdl to a table in the database DiagSwdlSession
      </description>
      <dependencies list="install.all.eswdl.files"/>
      <parameters>
        <parameter name="connectionstring" value="${diagswdlsession.cs}"/>
        <parameter name="sp.name" value="dbo.UpdateKeyValue"/>
        <parameter name="sp.parameter.1" value="parametername=@key;sqldbtype=nvarchar;length=50;value=eswdl.root.dir" />
        <parameter name="sp.parameter.2" value="parametername=@value;sqldbtype=nvarchar;length=250;value=${target.eswdl.root}" />
        <parameter name="sp.parameter.3" value="parametername=@description;sqldbtype=nvarchar;length=250;value=ESWDL directory"/>
      </parameters>
    </task>

  </tasks>
</taskrunner>